Last updated: 2024-02-27

Checks: 5 2

Knit directory: PD1_mm/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20240223) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Using absolute paths to the files within your workflowr project makes it difficult for you and others to run your code on a different machine. Change the absolute path(s) below to the suggested relative path(s) to make your code more reproducible.

absolute relative
/home/hnatri/PD1_mm/ .
/home/hnatri/PD1_mm/code/utilities.R code/utilities.R
/home/hnatri/PD1_mm/code/PD1_mm_themes.R code/PD1_mm_themes.R
/home/hnatri/PD1_mm/code/CART_plot_functions.R code/CART_plot_functions.R

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 18c1bd4. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    analysis/figure/

Untracked files:
    Untracked:  Layer1_DoHeatmap.pdf
    Untracked:  Layer1_UMAP.pdf
    Untracked:  Layer1_UMAP_DotPlot.pdf
    Untracked:  Layer1_scImmuCC_label.csv
    Untracked:  Layer1_tSNE.pdf
    Untracked:  Layer2_Bcell_DoHeatmap.pdf
    Untracked:  Layer2_Bcell_UMAP.pdf
    Untracked:  Layer2_Bcell_UMAP_DotPlot.pdf
    Untracked:  Layer2_Bcell_scImmuCC_label.csv
    Untracked:  Layer2_Bcell_tSNE.pdf
    Untracked:  Layer2_DC_DoHeatmap.pdf
    Untracked:  Layer2_DC_UMAP.pdf
    Untracked:  Layer2_DC_UMAP_DotPlot.pdf
    Untracked:  Layer2_DC_scImmuCC_label.csv
    Untracked:  Layer2_DC_tSNE.pdf
    Untracked:  Layer2_ILC_scImmuCC_label.csv
    Untracked:  Layer2_Macrophage_DoHeatmap.pdf
    Untracked:  Layer2_Macrophage_UMAP.pdf
    Untracked:  Layer2_Macrophage_UMAP_DotPlot.pdf
    Untracked:  Layer2_Macrophage_scImmuCC_label.csv
    Untracked:  Layer2_Macrophage_tSNE.pdf
    Untracked:  Layer2_Monocyte_DoHeatmap.pdf
    Untracked:  Layer2_Monocyte_UMAP.pdf
    Untracked:  Layer2_Monocyte_UMAP_DotPlot.pdf
    Untracked:  Layer2_Monocyte_scImmuCC_label.csv
    Untracked:  Layer2_Monocyte_tSNE.pdf
    Untracked:  Layer2_NK_DoHeatmap.pdf
    Untracked:  Layer2_NK_UMAP.pdf
    Untracked:  Layer2_NK_UMAP_DotPlot.pdf
    Untracked:  Layer2_NK_scImmuCC_label.csv
    Untracked:  Layer2_NK_tSNE.pdf
    Untracked:  Layer2_Tcell_DoHeatmap.pdf
    Untracked:  Layer2_Tcell_UMAP.pdf
    Untracked:  Layer2_Tcell_UMAP_DotPlot.pdf
    Untracked:  Layer2_Tcell_scImmuCC_label.csv
    Untracked:  Layer2_Tcell_tSNE.pdf
    Untracked:  Layer3_CD4_DoHeatmap.pdf
    Untracked:  Layer3_CD4_UMAP.pdf
    Untracked:  Layer3_CD4_UMAP_DotPlot.pdf
    Untracked:  Layer3_CD4_scImmuCC_label.csv
    Untracked:  Layer3_CD4_tSNE.pdf
    Untracked:  Layer3_CD8_DoHeatmap.pdf
    Untracked:  Layer3_CD8_UMAP.pdf
    Untracked:  Layer3_CD8_UMAP_DotPlot.pdf
    Untracked:  Layer3_CD8_scImmuCC_label.csv
    Untracked:  Layer3_CD8_tSNE.pdf

Unstaged changes:
    Modified:   analysis/annotate.Rmd
    Modified:   analysis/comparative_analysis.Rmd
    Modified:   analysis/processing.Rmd
    Modified:   cluster_markers.tsv
    Modified:   code/utilities.R

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/comparative_analysis.Rmd) and HTML (docs/comparative_analysis.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 18c1bd4 heinin 2024-02-27 Cell type proportion testing
html 18c1bd4 heinin 2024-02-27 Cell type proportion testing
Rmd 3e207b9 heinin 2024-02-26 Added scImmuCC annotations
Rmd 196db6a heinin 2024-02-26 Starting the comparative analysis

Introduction

Adding annotations and comparing treatment groups/timepoints.

Packages and environment variables

suppressPackageStartupMessages({
  #library(cli)
  library(Seurat)
  library(SeuratObject)
  library(SeuratDisk)
  library(tidyverse)
  library(tibble)
  library(ggplot2)
  library(ggpubr)
  library(ggrepel)
  library(workflowr)
  library(googlesheets4)
  library(scProportionTest)})

setwd("/home/hnatri/PD1_mm/")
set.seed(9999)
options(ggrepel.max.overlaps = Inf)

# Colors, themes, cell type markers, and plot functions
source("/home/hnatri/PD1_mm/code/utilities.R")
source("/home/hnatri/PD1_mm/code/PD1_mm_themes.R")
source("/home/hnatri/PD1_mm/code/CART_plot_functions.R")

Importing data

seurat_data <- readRDS("/tgen_labs/banovich/BCTCSF/PD1_mm_Seurat/PD1_mm_Seurat_merged.Rds")

DimPlot of cell type annotations

celltypes <- sort(as.character(unique(seurat_data$celltype)))
plot_colors <- colorRampPalette(brewer.pal(11, "Paired"))(length(celltypes))
names(plot_colors) <- celltypes

DimPlot(seurat_data,
        group.by = "celltype",
        reduction = "umap",
        raster = T,
        label = T,
        cols = plot_colors) &
  coord_fixed(ratio = 1) &
  theme_bw() &
  NoLegend()

Version Author Date
18c1bd4 heinin 2024-02-27
DimPlot(seurat_data,
        group.by = "celltype",
        split.by = "Treatment",
        reduction = "umap",
        raster = T,
        #label = T,
        cols = plot_colors) &
  coord_fixed(ratio = 1) &
  theme_bw() &
  NoLegend()

Cell type proportion differences

In scatter plots, the proportions of cell types in each pair of treatment groups are plotted against each other with one group on each axis. The forest plots show the significance level.

unique(seurat_data$Treatment)
[1] "ADJ"  "CTRL" "NEO" 
unique(seurat_data$Day)
[1] 16 12
table(seurat_data$celltype, seurat_data$Treatment)
       
         ADJ CTRL  NEO
  M1    1090 2163 1603
  Mono1  436 1444 2735
  M2     910 1634 1452
  L1     571 1420 1475
  Neut1  526 1498 1321
  L2    1117 1045 1063
  NK     579  992 1167
  M3     449 1117 1054
  M4     502  921 1107
  M5     252  665 1454
  NOS1   251 1619  498
  DC     379  773  772
  M6     132  763  590
  B1     311  568  553
  Treg   178  521  523
  M7     160  403  615
  B2     171  320  347
  L3     269  305  225
  L4      50  154  371
  M8      20  281  185
create_clusterpropplot(seurat_data,
                       group_var = "Treatment",
                       group1 = "ADJ",
                       group2 = "CTRL",
                       plot_var = "celltype",
                       plot_colors = plot_colors,
                       var_names = c("ADJ", "CTRL"),
                       legend_title = "Treatment")
Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
ℹ Please use tidy evaluation idioms with `aes()`.
ℹ See also `vignette("ggplot2-in-packages")` for more information.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.

Version Author Date
18c1bd4 heinin 2024-02-27
create_clusterpropplot(seurat_data,
                       group_var = "Treatment",
                       group1 = "NEO",
                       group2 = "CTRL",
                       plot_var = "celltype",
                       plot_colors = plot_colors,
                       var_names = c("NEO", "CTRL"),
                       legend_title = "Treatment")

Version Author Date
18c1bd4 heinin 2024-02-27
create_clusterpropplot(seurat_data,
                       group_var = "Treatment",
                       group1 = "ADJ",
                       group2 = "NEO",
                       plot_var = "celltype",
                       plot_colors = plot_colors,
                       var_names = c("ADJ", "NEO"),
                       legend_title = "Treatment")

Version Author Date
18c1bd4 heinin 2024-02-27
# Day 12
create_clusterpropplot(subset(seurat_data, subset = Day == 12),
                       group_var = "Treatment",
                       group1 = "NEO",
                       group2 = "CTRL",
                       plot_var = "celltype",
                       plot_colors = plot_colors,
                       var_names = c("NEO", "CTRL"),
                       legend_title = "Treatment, Day 12")

Version Author Date
18c1bd4 heinin 2024-02-27
# Day 16
create_clusterpropplot(subset(seurat_data, subset = Day == 16),
                       group_var = "Treatment",
                       group1 = "ADJ",
                       group2 = "CTRL",
                       plot_var = "celltype",
                       plot_colors = plot_colors,
                       var_names = c("ADJ", "CTRL"),
                       legend_title = "Treatment, Day 16")

Version Author Date
18c1bd4 heinin 2024-02-27
create_clusterpropplot(subset(seurat_data, subset = Day == 16),
                       group_var = "Treatment",
                       group1 = "NEO",
                       group2 = "CTRL",
                       plot_var = "celltype",
                       plot_colors = plot_colors,
                       var_names = c("NEO", "CTRL"),
                       legend_title = "Treatment, Day 16")

Version Author Date
18c1bd4 heinin 2024-02-27
create_clusterpropplot(subset(seurat_data, subset = Day == 16),
                       group_var = "Treatment",
                       group1 = "ADJ",
                       group2 = "NEO",
                       plot_var = "celltype",
                       plot_colors = plot_colors,
                       var_names = c("ADJ", "NEO"),
                       legend_title = "Treatment, Day 16")

Version Author Date
18c1bd4 heinin 2024-02-27
# Using scProportionTest
prop_test <- sc_utils(seurat_data)

prop_test <- permutation_test(
  prop_test, cluster_identity = "celltype",
  sample_1 = "CTRL", sample_2 = "ADJ",
  sample_identity = "Treatment")

perm_plot <- permutation_plot(prop_test)

perm_plot + scale_colour_manual(values = c("tomato", "azure2")) +
  #NoLegend() +
  ggtitle("ADJ vs. CTRL, all timepoints")
Scale for colour is already present.
Adding another scale for colour, which will replace the existing scale.

Version Author Date
18c1bd4 heinin 2024-02-27
prop_test <- permutation_test(
  prop_test, cluster_identity = "celltype",
  sample_1 = "CTRL", sample_2 = "NEO",
  sample_identity = "Treatment")

perm_plot <- permutation_plot(prop_test)

perm_plot + scale_colour_manual(values = c("tomato", "azure2")) +
  #NoLegend() +
  ggtitle("NEO vs. CTRL, all timepoints")
Scale for colour is already present.
Adding another scale for colour, which will replace the existing scale.

Version Author Date
18c1bd4 heinin 2024-02-27
prop_test <- permutation_test(
  prop_test, cluster_identity = "celltype",
  sample_1 = "ADJ", sample_2 = "NEO",
  sample_identity = "Treatment")

perm_plot <- permutation_plot(prop_test)

perm_plot + scale_colour_manual(values = c("tomato", "azure2")) +
  #NoLegend() +
  ggtitle("NEO vs. ADJ, all timepoints")
Scale for colour is already present.
Adding another scale for colour, which will replace the existing scale.

Version Author Date
18c1bd4 heinin 2024-02-27
# Day 12 only
# For day 12, no ADJ sample
prop_test <- sc_utils(subset(seurat_data, subset = Day == 12))

prop_test <- permutation_test(
  prop_test, cluster_identity = "celltype",
  sample_1 = "CTRL", sample_2 = "NEO",
  sample_identity = "Treatment")

perm_plot <- permutation_plot(prop_test)

perm_plot + scale_colour_manual(values = c("tomato", "azure2")) +
  #NoLegend() +
  ggtitle("NEO vs. CTRL, day 12")
Scale for colour is already present.
Adding another scale for colour, which will replace the existing scale.

Version Author Date
18c1bd4 heinin 2024-02-27
# Day 16 only
prop_test <- sc_utils(subset(seurat_data, subset = Day == 16))

prop_test <- permutation_test(
  prop_test, cluster_identity = "celltype",
  sample_1 = "CTRL", sample_2 = "ADJ",
  sample_identity = "Treatment")

perm_plot <- permutation_plot(prop_test)

perm_plot + scale_colour_manual(values = c("tomato", "azure2")) +
  #NoLegend() +
  ggtitle("ADJ vs. CTRL, day 16")
Scale for colour is already present.
Adding another scale for colour, which will replace the existing scale.

Version Author Date
18c1bd4 heinin 2024-02-27
prop_test <- permutation_test(
  prop_test, cluster_identity = "celltype",
  sample_1 = "CTRL", sample_2 = "NEO",
  sample_identity = "Treatment")

perm_plot <- permutation_plot(prop_test)

perm_plot + scale_colour_manual(values = c("tomato", "azure2")) +
  #NoLegend() +
  ggtitle("NEO vs. CTRL, day 16")
Scale for colour is already present.
Adding another scale for colour, which will replace the existing scale.

Version Author Date
18c1bd4 heinin 2024-02-27
prop_test <- permutation_test(
  prop_test, cluster_identity = "celltype",
  sample_1 = "ADJ", sample_2 = "NEO",
  sample_identity = "Treatment")

perm_plot <- permutation_plot(prop_test)

perm_plot + scale_colour_manual(values = c("tomato", "azure2")) +
  #NoLegend() +
  ggtitle("NEO vs. ADJ, day 16")
Scale for colour is already present.
Adding another scale for colour, which will replace the existing scale.

Version Author Date
18c1bd4 heinin 2024-02-27

sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: Etc/UTC
tzcode source: system (glibc)

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] ComplexHeatmap_2.18.0       viridis_0.6.3              
 [3] viridisLite_0.4.2           circlize_0.4.15            
 [5] plyr_1.8.8                  RColorBrewer_1.1-3         
 [7] scProportionTest_0.0.0.9000 googlesheets4_1.1.0        
 [9] workflowr_1.7.1             ggrepel_0.9.3              
[11] ggpubr_0.6.0                lubridate_1.9.2            
[13] forcats_1.0.0               stringr_1.5.0              
[15] dplyr_1.1.2                 purrr_1.0.1                
[17] readr_2.1.4                 tidyr_1.3.0                
[19] tibble_3.2.1                ggplot2_3.4.2              
[21] tidyverse_2.0.0             SeuratDisk_0.0.0.9021      
[23] Seurat_5.0.1                SeuratObject_5.0.1         
[25] sp_1.6-1                   

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.20       splines_4.3.0          later_1.3.1           
  [4] cellranger_1.1.0       polyclip_1.10-4        fastDummies_1.7.3     
  [7] lifecycle_1.0.3        rstatix_0.7.2          doParallel_1.0.17     
 [10] rprojroot_2.0.3        globals_0.16.2         processx_3.8.1        
 [13] lattice_0.21-8         hdf5r_1.3.8            MASS_7.3-60           
 [16] backports_1.4.1        magrittr_2.0.3         plotly_4.10.2         
 [19] sass_0.4.6             rmarkdown_2.22         jquerylib_0.1.4       
 [22] yaml_2.3.7             httpuv_1.6.11          sctransform_0.4.1     
 [25] spam_2.9-1             spatstat.sparse_3.0-1  reticulate_1.29       
 [28] cowplot_1.1.1          pbapply_1.7-0          abind_1.4-5           
 [31] Rtsne_0.16             BiocGenerics_0.48.1    git2r_0.32.0          
 [34] S4Vectors_0.40.2       IRanges_2.36.0         irlba_2.3.5.1         
 [37] listenv_0.9.0          spatstat.utils_3.0-3   goftest_1.2-3         
 [40] RSpectra_0.16-1        spatstat.random_3.1-5  fitdistrplus_1.1-11   
 [43] parallelly_1.36.0      leiden_0.4.3           codetools_0.2-19      
 [46] tidyselect_1.2.0       shape_1.4.6            farver_2.1.1          
 [49] stats4_4.3.0           matrixStats_1.0.0      spatstat.explore_3.2-1
 [52] googledrive_2.1.0      jsonlite_1.8.5         GetoptLong_1.0.5      
 [55] ellipsis_0.3.2         progressr_0.13.0       iterators_1.0.14      
 [58] ggridges_0.5.4         survival_3.5-5         foreach_1.5.2         
 [61] tools_4.3.0            ica_1.0-3              Rcpp_1.0.10           
 [64] glue_1.6.2             gridExtra_2.3          xfun_0.39             
 [67] withr_2.5.0            fastmap_1.1.1          fansi_1.0.4           
 [70] callr_3.7.3            digest_0.6.31          timechange_0.2.0      
 [73] R6_2.5.1               mime_0.12              colorspace_2.1-0      
 [76] scattermore_1.2        tensor_1.5             spatstat.data_3.0-1   
 [79] utf8_1.2.3             generics_0.1.3         data.table_1.14.8     
 [82] httr_1.4.6             htmlwidgets_1.6.2      whisker_0.4.1         
 [85] uwot_0.1.14            pkgconfig_2.0.3        gtable_0.3.3          
 [88] lmtest_0.9-40          htmltools_0.5.5        carData_3.0-5         
 [91] dotCall64_1.0-2        clue_0.3-64            scales_1.2.1          
 [94] png_0.1-8              knitr_1.43             rstudioapi_0.14       
 [97] rjson_0.2.21           tzdb_0.4.0             reshape2_1.4.4        
[100] nlme_3.1-162           cachem_1.0.8           zoo_1.8-12            
[103] GlobalOptions_0.1.2    KernSmooth_2.23-21     parallel_4.3.0        
[106] miniUI_0.1.1.1         pillar_1.9.0           vctrs_0.6.2           
[109] RANN_2.6.1             promises_1.2.0.1       car_3.1-2             
[112] xtable_1.8-4           cluster_2.1.4          evaluate_0.21         
[115] cli_3.6.1              compiler_4.3.0         rlang_1.1.1           
[118] crayon_1.5.2           future.apply_1.11.0    ggsignif_0.6.4        
[121] labeling_0.4.2         ps_1.7.5               getPass_0.2-4         
[124] fs_1.6.2               stringi_1.7.12         deldir_1.0-9          
[127] munsell_0.5.0          lazyeval_0.2.2         spatstat.geom_3.2-1   
[130] Matrix_1.6-5           RcppHNSW_0.5.0         hms_1.1.3             
[133] patchwork_1.1.2        bit64_4.0.5            future_1.32.0         
[136] shiny_1.7.4            highr_0.10             ROCR_1.0-11           
[139] gargle_1.4.0           igraph_1.4.3           broom_1.0.4           
[142] bslib_0.4.2            bit_4.0.5